<?php


namespace app\admin\model\view;

use app\logic\model\view\OpusNumber_opus_userView as OpusNumber_opus_user;
class OpusNumber_opus_userView extends OpusNumber_opus_user
{
    function getList($request,$field,$limit,$sort='id desc'){
        $list=$this
            ->where(function($q) use ($request){
                if(check_request($request,"title")){
                    $q->whereLike("opus_title","%{$request['title']}%");
                }
                if(check_request($request,'opus_id')){
                	$q->where("opus_id",$request['opus_id']);
                }
                if(check_request($request,"writer_name")){
                    $q->whereLike("writer.nickname|writer.true_name","%{$request['writer_name']}%");
                }
                if(check_request($request,"opus_number")){
                    $q->whereLike("number","%{$request['opus_number']}%");
                }
                if(check_request($request,"status")){
                    $q->whereLike("status",$request['status']);
                }
            })
            ->field($field)
            ->order($sort)
            ->paginate($limit);
        if(!$list->isEmpty()){
            return $list->toArray();
        }else{
            return $list;
        }
    }
    function findByid($id){
        $item=$this->where("id",$id)->find();
        return $item;
    }
}